﻿using Bll;
using Help;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace Myproject.BSM.Ashx.PcChannel
{
    /// <summary>
    /// GoodsclassEdit 的摘要说明
    /// </summary>
    public class GoodsclassEdit : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string id = context.Request.Form["pc_Channel_GoodsclassEdit_GoodsclassId"];
            string name = context.Request.Form["pc_Channel_GoodsclassEdit_name"];
            string ename = context.Request.Form["pc_Channel_GoodsclassEdit_ename"];
            if (id == "0")
            {
                GoodsClassModel model = new GoodsClassModel();
                model.Name = name;
                model.EName = ename;
                model.Show = true;
                model.Rank = 1;
                if (new GoodsClassBLL().Add(model) > 0)
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(200, "添加类别成功！", "pc_channel_GoodsclassList", "", "", true, "", ""));
                }
                else
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(300, "添加类别失败！", "pc_channel_GoodsclassList", "", "", true, "", ""));
                }
            }
            else
            {
                GoodsClassModel model = new GoodsClassBLL().GetModel(int.Parse(id));
                model.Name = name;
                model.EName = ename;
                if (new GoodsClassBLL().Update(model))
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(200, "修改类别成功！", "pc_channel_GoodsclassList", "", "", true, "", ""));
                }
                else
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(300, "修改类别失败！", "pc_channel_GoodsclassList", "", "", true, "", ""));
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}